<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>登录 - 数据库教学系统</title>
  <link rel="stylesheet" href="/src/style.css">
  <link rel="stylesheet" href="/node_modules/@fortawesome/fontawesome-free/css/all.min.css">
</head>
<body class="min-h-screen bg-gray-50 flex items-center justify-center p-4">
  <div class="w-full max-w-md">
    <div class="text-center mb-8">
      <h1 class="text-2xl font-bold text-gray-900 mb-2">数据库教学系统</h1>
      <p class="text-gray-600">请登录以访问您的账户</p>
    </div>

    <div class="card">
      <form class="space-y-6" id="loginForm">
        <div>
          <label for="username" class="block text-sm font-medium text-gray-700 mb-1">用户名</label>
          <div class="relative">
            <span class="absolute inset-y-0 left-0 pl-3 flex items-center text-gray-500">
              <i class="fas fa-user"></i>
            </span>
            <input type="text" id="username" name="username" required
              class="input pl-10" placeholder="请输入用户名">
          </div>
        </div>

        <div>
          <label for="password" class="block text-sm font-medium text-gray-700 mb-1">密码</label>
          <div class="relative">
            <span class="absolute inset-y-0 left-0 pl-3 flex items-center text-gray-500">
              <i class="fas fa-lock"></i>
            </span>
            <input type="password" id="password" name="password" required
              class="input pl-10" placeholder="请输入密码">
          </div>
        </div>

        <div class="flex items-center justify-between">
          <div class="flex items-center">
            <input id="remember-me" name="remember-me" type="checkbox"
              class="h-4 w-4 text-primary border-gray-300 rounded focus:ring-primary">
            <label for="remember-me" class="ml-2 block text-sm text-gray-700">记住我</label>
          </div>
          <a href="#" class="text-sm text-primary hover:text-blue-600">忘记密码？</a>
        </div>

        <button type="submit" class="w-full btn btn-primary">
          <i class="fas fa-sign-in-alt mr-2"></i>登录
        </button>
      </form>
    </div>
  </div>

  <script>
    document.getElementById('loginForm').addEventListener('submit', function(e) {
      e.preventDefault();
      
      const username = document.getElementById('username').value;
      const password = document.getElementById('password').value;
      
      // 这里简单判断用户名前缀来区分角色，实际应该通过后端API验证
      if (username && password) {
        if (username.startsWith('T')) {
          // 教师账号
          window.location.href = '/src/pages/dashboard.html';
        } else if (username.startsWith('S')) {
          // 学生账号
          window.location.href = '/src/pages/student/dashboard.html';
        } else {
          alert('用户名或密码错误');
        }
      }
    });
  </script>
</body>
</html>